package cn.xfdzx.android.apps.shop.presenter;

import java.util.Map;

import cn.xfdzx.android.apps.shop.base.BasePresenter;
import cn.xfdzx.android.apps.shop.bean.ApplyShopInBeen;
import cn.xfdzx.android.apps.shop.bean.BankCardBeen;
import cn.xfdzx.android.apps.shop.bean.EleContractMakeBeen;
import cn.xfdzx.android.apps.shop.bean.LicenseImgBeen;
import cn.xfdzx.android.apps.shop.bean.OneBeen;
import cn.xfdzx.android.apps.shop.contract.ApplyShopInContract;
import cn.xfdzx.android.apps.shop.contract.ShopInContract;
import cn.xfdzx.android.apps.shop.model.ApplyShopInModel;
import cn.xfdzx.android.apps.shop.model.ShopInModel;
import cn.xfdzx.android.apps.shop.net.RxScheduler;
import io.reactivex.functions.Consumer;

/**
 * @author azheng
 * @date 2018/6/4.
 * Description：
 */
public class ApplyShopInPresenter extends BasePresenter<ApplyShopInContract.View> implements ApplyShopInContract.Presenter {

    private ApplyShopInContract.Model model;

    public ApplyShopInPresenter() {
        model = new ApplyShopInModel();
    }


    @Override
    public void applySubmit(String idcard,String offline_shop_name,String whole_address,String inv_code,String lat,String lng,String store_name, String store_master, String store_qualifications_img, String store_category, String store_address, String store_phone, String store_qualifications_num, String store_qualifications_name, String store_qualifications_expire, String idcard_back_img, String idcard_front_img, String qs_img, String bank_card, String bank_open_name, String bank_name, String bank_branch, String bd_name, String bd_phone, String sign_status, String bd_content, String store_logo, String category_id, String store_current_address, String intro, String salecate, String front_door_photo, String in_store_photo) {
        if (!isViewAttached()) {
            return;
        }
        mView.showLoading();
        model.applySubmit(idcard,offline_shop_name,whole_address,inv_code,lat,lng, store_name,  store_master,  store_qualifications_img,  store_category,  store_address,  store_phone,  store_qualifications_num,  store_qualifications_name,  store_qualifications_expire,  idcard_back_img,  idcard_front_img,  qs_img,  bank_card,  bank_open_name,  bank_name,  bank_branch,  bd_name,  bd_phone,  sign_status,  bd_content,  store_logo,  category_id,  store_current_address,  intro,  salecate,  front_door_photo,  in_store_photo)
                .compose(RxScheduler.<ApplyShopInBeen>Flo_io_main())
                .as(mView.<ApplyShopInBeen>bindAutoDispose())
                .subscribe(new Consumer<ApplyShopInBeen>() {
                    @Override
                    public void accept(ApplyShopInBeen bean) throws Exception {
                        mView.onApplySubmitSuccess(bean);
                        mView.hideLoading();
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        mView.onError(throwable);
                        mView.hideLoading();
                    }
                });
    }
    @Override
    public void idCardSubmit(String bankCardImg) {
        if (!isViewAttached()) {
            return;
        }
        mView.showLoading();
        model.idCardSubmit(bankCardImg)
                .compose(RxScheduler.<BankCardBeen>Flo_io_main())
                .as(mView.<BankCardBeen>bindAutoDispose())
                .subscribe(new Consumer<BankCardBeen>() {
                    @Override
                    public void accept(BankCardBeen bean) throws Exception {
                        mView.onBankCardSuccess(bean);
                        mView.hideLoading();
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        mView.onError(throwable);
                        mView.hideLoading();
                    }
                });
    }

    @Override
    public void eleContractMake(String contract_year,String store_num,String telephone,String card_name,String card_code,String customer_name,String orgnizationCode,String orgnizationMster,String customer_address,String bank_name,String bank_code) {
        if (!isViewAttached()) {
            return;
        }
        mView.showLoading();
        model.eleContractMake(contract_year,store_num,telephone,card_name,card_code,customer_name,orgnizationCode,orgnizationMster,customer_address,bank_name,bank_code)
                .compose(RxScheduler.<EleContractMakeBeen>Flo_io_main())
                .as(mView.<EleContractMakeBeen>bindAutoDispose())
                .subscribe(new Consumer<EleContractMakeBeen>() {
                    @Override
                    public void accept(EleContractMakeBeen bean) throws Exception {
                        mView.onEleContractMakeSuccess(bean);
                        mView.hideLoading();
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        mView.onError(throwable);
                        mView.hideLoading();
                    }
                });
    }
}
